import requests
from bs4 import BeautifulSoup
import json
import re
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'}
url = 'https://slamdunk.sports.sina.com.cn/api?p=radar&callback=jQuery111308818318866610371_1715052597192&p=radar&s=team_standing&a=conference&_=1715052597193'
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text, 'html.parser')
t = soup.text
text = t.encode('utf-8').decode('unicode_escape')
list1 = re.search(".eastern.*]", text).group()
list2 = re.search(".western.*]", text).group()
list3 = list1.replace(","+list2, "")
eastern_list = list3.replace('''"eastern":''',"")
western_list = list2.replace('''"western":''', "")
total = (eastern_list+western_list).replace("][","")
with open('data.json', 'w', encoding='utf-8') as f:
    json.dump(total, f, ensure_ascii=False, indent=4)
    print("导入成功")



